<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">产品代码（SAM推送）产品代码</label>
        <el-input v-model="query.prodCode" clearable placeholder="产品代码（SAM推送）产品代码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="表名">
            <el-input v-model="form.fpssProdInfo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品代码" prop="prodCode">
            <el-input v-model="form.prodCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品名称">
            <el-input v-model="form.prodName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品简称">
            <el-input v-model="form.prodNameAbb" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品创建地区">
            <el-input v-model="form.createArea" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品创建机构">
            <el-input v-model="form.createOrgno" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品模型">
            <el-input v-model="form.prodBase" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售币种">
            <el-input v-model="form.salesCur" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品风险等级">
            <el-input v-model="form.prodRiskLevel" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="认购起始日">
            <el-input v-model="form.subsBeginDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="认购结束日">
            <el-input v-model="form.subsEndDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="认购归集日">
            <el-input v-model="form.establishDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="起息日">
            <el-input v-model="form.valueDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="到期日">
            <el-input v-model="form.endDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="到期兑付日">
            <el-input v-model="form.payDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="日切时间">
            <el-input v-model="form.transCloseTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="申购确认时效（天）">
            <el-input v-model="form.subsN" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="赎回确认时效（天）">
            <el-input v-model="form.redeemN" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许销售的渠道">
            <el-input v-model="form.allowSalesChannel" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许的销售对象">
            <el-input v-model="form.allowCustType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许销售的卡种">
            <el-input v-model="form.allowCardType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许销售年龄上限">
            <el-input v-model="form.startAge" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许销售年龄下限">
            <el-input v-model="form.endAge" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="允许销售的客户层级">
            <el-input v-model="form.allowCustomType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否募集失败">
            <el-input v-model="form.isRaiseFail" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="产品状态">
            <el-input v-model="form.prodStatus" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售状态">
            <el-input v-model="form.salesStatus" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="收益浮动方式">
            <el-input v-model="form.incomeVaryType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否保本">
            <el-input v-model="form.capitalFlag" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="暂停交易业务">
            <el-input v-model="form.stopBusiCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="计息基础">
            <el-input v-model="form.yearDays" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="fpssProdInfo" label="表名" />
        <el-table-column prop="prodCode" label="产品代码" />
        <el-table-column prop="prodName" label="产品名称" />
        <el-table-column prop="prodNameAbb" label="产品简称" />
        <el-table-column prop="createArea" label="产品创建地区" />
        <el-table-column prop="createOrgno" label="产品创建机构" />
        <el-table-column prop="prodBase" label="产品模型" />
        <el-table-column prop="salesCur" label="销售币种" />
        <el-table-column prop="prodRiskLevel" label="产品风险等级" />
        <el-table-column prop="subsBeginDate" label="认购起始日" />
        <el-table-column prop="subsEndDate" label="认购结束日" />
        <el-table-column prop="establishDate" label="认购归集日" />
        <el-table-column prop="valueDate" label="起息日" />
        <el-table-column prop="endDate" label="到期日" />
        <el-table-column prop="payDate" label="到期兑付日" />
        <el-table-column prop="transCloseTime" label="日切时间" />
        <el-table-column prop="subsN" label="申购确认时效（天）" />
        <el-table-column prop="redeemN" label="赎回确认时效（天）" />
        <el-table-column prop="allowSalesChannel" label="允许销售的渠道" />
        <el-table-column prop="allowCustType" label="允许的销售对象" />
        <el-table-column prop="allowCardType" label="允许销售的卡种" />
        <el-table-column prop="startAge" label="允许销售年龄上限" />
        <el-table-column prop="endAge" label="允许销售年龄下限" />
        <el-table-column prop="allowCustomType" label="允许销售的客户层级" />
        <el-table-column prop="isRaiseFail" label="是否募集失败" />
        <el-table-column prop="prodStatus" label="产品状态" />
        <el-table-column prop="salesStatus" label="销售状态" />
        <el-table-column prop="incomeVaryType" label="收益浮动方式" />
        <el-table-column prop="capitalFlag" label="是否保本" />
        <el-table-column prop="stopBusiCode" label="暂停交易业务" />
        <el-table-column prop="yearDays" label="计息基础" />
        <el-table-column prop="createTime" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="updateTime" label="更新时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','prodInfo:edit','prodInfo:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudProdInfo from '@/api/biz/prodInfo'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultCrud=CRUD({ title: 'ProdInfo', url: 'api/prodInfo', idField: 'prodCode', sort: 'prodCode,desc', crudMethod: { ...crudProdInfo }})
const defaultForm = { fpssProdInfo: null, prodCode: null, prodName: null, prodNameAbb: null, createArea: null, createOrgno: null, prodBase: null, salesCur: null, prodRiskLevel: null, subsBeginDate: null, subsEndDate: null, establishDate: null, valueDate: null, endDate: null, payDate: null, transCloseTime: null, subsN: null, redeemN: null, allowSalesChannel: null, allowCustType: null, allowCardType: null, startAge: null, endAge: null, allowCustomType: null, isRaiseFail: null, prodStatus: null, salesStatus: null, incomeVaryType: null, capitalFlag: null, stopBusiCode: null, yearDays: null, createTime: null, updateTime: null }
export default {
  name: 'ProdInfo',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],

  data() {
    return {
      permission: {
        add: ['admin', 'prodInfo:add'],
        edit: ['admin', 'prodInfo:edit'],
        del: ['admin', 'prodInfo:del']
      },
      rules: {
        prodCode: [
          { required: true, message: '产品代码（SAM推送）产品代码不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'prodCode', display_name: '产品代码（SAM推送）产品代码' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
